﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace XjjXmm.Spider.biquge
{
    internal class Setting
    {
        public static List<SiteSetting> SiteSettings { get; set; }         

        public static SiteSetting? FindSetting<T>() {
            var name = typeof(T).Name;
            return SiteSettings?.FirstOrDefault(x => x.Name == name);
        }

        

        public static List<string> GetKeys<T>()
        {
                                 var setting =          FindSetting<T>();
            if (setting == null)
            {
                return new List<string>();
            }

            var keys =  new List<string>();

            var i = 0;
            if(setting.UseLocal)
            {
                keys.Add($"{setting.Name}_{i}");
            }

            i++;

            setting.Proxylist?.ForEach(_ => {
                keys.Add($"{setting.Name}_{i}");
                i++;
            });
            return keys;
        }
    }

    internal class SiteSetting
    {
        public string Name { get; set; }
        public string Domain { get; set; }

        public bool IsActived { get; set; }

        public List<string> Proxylist { get; set; }

        public bool UseLocal { get; set; }
    }
}
